<template>
 <div class="header-swiper bgcolor">
    <swiper ref="mySwiper" :options="swiperOptions">
      <swiper-slide class="heads" v-for="(item,key) in page" :key="key">
        <div class="items" v-for="page in item" :key="page.id">
          <img :src="page.imgUrl" alt="">
          <p>{{page.tiele}}</p>
        </div>
      </swiper-slide>
    </swiper>
 </div>
</template>


<script>
// import 'assets/css/reset.css';

export default {
  name: 'Home',
  props: ['IconsList'],
  data () {
    return {
      swiperOptions: {},
       
    }
  },
  computed: {
    // 利用函数实现数据分页效果
    page() {
      let pages = [];
      // 二维数组
      this.IconsList.forEach((item,index)=> {
        // 向下取整
        let idx = Math.floor(index/8);
        // 如果没有则为空
        if(!pages[idx]) pages[idx] = [];
        pages[idx].push(item);
      });
      return pages;
    }
  }
}
</script>

<style lang="less" scoped>
  .header-swiper {
    padding: 0.1rem;
    .heads {
      display: flex;
      flex-wrap: wrap;
      font-size: 0.12rem;
      .items {
        flex: 25%;
        display: flex;
        flex-direction: column;
        align-items: center;
        flex-grow: 0;
        padding: 0.1rem 0 0.1rem 0;

        img {
            width: 0.4rem;
        }
      }
    }
     
  }
</style>
